package com.wpw.dream.queue;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.LinkedBlockingQueue;

public class QueueTest {

	public static void main(String[] args) throws InterruptedException {
		ConcurrentLinkedQueue<String> cq = new ConcurrentLinkedQueue<>();
		
		cq.add("d");
		
		ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>();
		map.put("dd", "dd");
		
		ArrayBlockingQueue<Integer> aq = new ArrayBlockingQueue<>(1000000);
		long aStart = System.currentTimeMillis();
		for (int i = 0; i < 1000000; i++) {
			aq.add(i);
		}
		aq.take();
		aq.peek();
		
		aq.remove();

		aq.offer(1);
		System.out.println("ArrayBlockingQueue耗时" + (System.currentTimeMillis() - aStart));
		
		LinkedBlockingQueue<Integer> lq = new LinkedBlockingQueue<>();
		long lStart = System.currentTimeMillis();
		for (int i = 0; i < 1000000; i++) {
			lq.add(i);
		}
		lq.take();
		lq.peek();
		
		lq.remove();

		lq.offer(1);
		
		lq.remove();
		System.out.println("LinkedBlockingQueue耗时" + (System.currentTimeMillis() - lStart));
		
		LinkedBlockingQueue<String> q = new LinkedBlockingQueue<>(2);
		q.add("a");
		q.add("b");
		q.put("c");
		
		ArrayBlockingQueue<String> fairaq = new ArrayBlockingQueue<>(100, true);
		
	}
}
